﻿#define _CRT_SECURE_NO_WARNINGS 1
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<math.h>
#include<stdlib.h>
#include<stdio.h>
#include<unordered_map>
#include<queue>
#include<stack>
#include <functional>
#include<queue>
#include <memory>
using namespace std;

int main() {
    string s;
    cin >> s;
    int n;
    cin >> n;
    string ret;
    int  max = 0;
    ret = s.substr(0, n);
    int left = 0, right = 0;
    int len = s.size();
    int sum = 0;
    while (right < len) {
        if (s[right] == 'C' || s[right] == 'G') sum++;
        if (right - left + 1 == n)
        {
            if (sum > max)
            {
                max = sum;
                ret = s.substr(left, n);
            }
            if (s[left] == 'C' || s[left] == 'G') sum--;
            left++;
        }
        right++;
    }
    cout << ret;
    return 0;
}